package org.example.infrastructure.repository.orm.database;

import lombok.RequiredArgsConstructor;
import org.example.domain.model.entity.url.UrlShortenerGroup;
import org.example.domain.model.entity.url.req.UrlShortenerGroupSortReq;
import org.example.domain.repository.UrlGroupDomainRepository;
import org.example.infrastructure.persistence.orm.UrlGroupMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@RequiredArgsConstructor
public class MybatisUrlGroupDomainRepository implements UrlGroupDomainRepository {
    private final UrlGroupMapper urlGroupMapper;


    @Override
    public Integer selectCountByUserName(String userName) {
        return urlGroupMapper.selectCountByUserName(userName);
    }

    @Override
    public void insertGroup(UrlShortenerGroup urlShortenerGroup) {
        urlGroupMapper.insert(urlShortenerGroup);
    }

    @Override
    public List<UrlShortenerGroup> listGroupByUserName(String userName) {
        return urlGroupMapper.listGroupByUserName(userName);
    }

    @Override
    public void updateGroup(String gid, String userName, String groupName) {
        urlGroupMapper.updateGroup(gid, userName, groupName);
    }

    @Override
    public void deleteGroup(String gid, String userName) {
        urlGroupMapper.deleteGroup(gid, userName);
    }

    @Override
    public void sortGroup(List<UrlShortenerGroupSortReq> reqList, String userName) {
        urlGroupMapper.sortGroup(reqList, userName);
    }

    @Override
    public List<String> selectGitListByUserName(String userName) {
        return urlGroupMapper.selectGitListByUserName(userName);
    }
}
